<?php namespace App\Http\Controllers;

use Log;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Config;
use Qiniu\Auth;
use App\Models\User;
use App\Utils\ReturnUtils;

class TestController extends Controller
{
    //获取验证码
    public function testNotify() {
        $mytest = new User();
        $mytest->Mytestuserinfo();
    }
    
    //获取验证码
    public function verifyCode(Request $request) {
        $returnUtils = new ReturnUtils($request);
        $data = with(new User($request))->verifyCode();
        if(!$data){
            return $returnUtils->returnError($returnUtils->return['ERROR_USER_GETINFO']);
        }
        return $returnUtils->returnOk($returnUtils->return['SUCCESS'], $data);
    }
    
    //登陆-注册
    public function login(Request $request) {
        $returnUtils = new ReturnUtils($request);
        $data = with(new User($request))->login();
        if(!$data){
            return $returnUtils->returnError($returnUtils->return['ERROR_USER_GETINFO']);
        }
        return $returnUtils->returnOk($returnUtils->return['SUCCESS'], $data);
    }
    
    //更新用户信息
    public function updateUserInfo(Request $request) {
        $returnUtils = new ReturnUtils($request);
        $data = with(new User($request))->updateUserInfo();
        if(!$data){
            return $returnUtils->returnError($returnUtils->return['ERROR_USER_GETINFO']);
        }
        return $returnUtils->returnOk($returnUtils->return['SUCCESS'], $data);
    }
    
    //获取用户信息
    public function getUserInfo(Request $request) {
        $returnUtils = new ReturnUtils($request);
        $data = with(new User($request))->getUserInfo();
        if(!$data){
            return $returnUtils->returnError($returnUtils->return['ERROR_USER_GETINFO']);
        }
        return $returnUtils->returnOk($returnUtils->return['SUCCESS'], $data);
    }
    
    
}
